use_framework = ENV['USE_FRAMEWORK']
dev_framework = ENV['USE_DEV_FRAMEWORK_BTDiscover']
use_framework = dev_framework ? false : use_framework

# 支持的混淆模式, 例如：SUPPORT_MIXUP = ['XXX', 'YYY']
SUPPORT_MIXUP = ['MNL']

# Beta版本 默认不包含BT 例如：BETA_SUPPORT_MIXUP = ['VO']
BETA_SUPPORT_MIXUP = ['MNL']

Pod::Spec.new do |s|
  s.name             = 'BTDiscover'
  s.version          = '119.b7'
  s.summary          = '发现页面.'

  s.description      = <<-DESC
  发现页面.
                       DESC

 git_source = use_framework ? "https://gitlab.v.show/ios_framework/#{s.name.to_s}.git" : "https://gitlab.v.show/ios_component/#{s.name.to_s}.git"

  s.homepage         = git_source
  s.author           = { '邬学丹' => 'xd.wu@liaoke.tv' }

# unless use_framework
  zip_file_path = s.version.to_s.include?('.b') ? "repository/files/#{s.version.to_s.split('.b')[0]}-beta" : s.version.to_s.include?('.swift') ? "repository/files/#{s.version.to_s.split('.swift')[0]}" : "repository/files/#{s.version.to_s}"
  if use_framework
    s.default_subspec = 'CoreFramework'
    s.source = {
      :http => "https://gitlab.v.show/api/v4/projects/368/#{zip_file_path}%2F#{s.name.to_s}-#{s.version.to_s}.zip/raw?ref=main",
      :http_ZSL => "https://gitlab.v.show/api/v4/projects/368/#{zip_file_path}%2FZSLDiscover-#{s.version.to_s}.zip/raw?ref=main",
      :http_PPL => "https://gitlab.v.show/api/v4/projects/368/#{zip_file_path}%2FPPLDiscover-#{s.version.to_s}.zip/raw?ref=main",
      :http_VO => "https://gitlab.v.show/api/v4/projects/368/#{zip_file_path}%2FVODiscover-#{s.version.to_s}.zip/raw?ref=main",
      :http_MNL => "https://gitlab.v.show/api/v4/projects/368/#{zip_file_path}%2FMNLDiscover-#{s.version.to_s}.zip/raw?ref=main",
      :type => "zip",
      :headers => ["Authorization: Bearer #{ENV['GIT_LAB_TOKEN']}"]
    }
  else
    s.default_subspec   = 'Core'
    s.license           = { :type => 'MIT', :file => 'LICENSE' }
    s.source            = { :git => git_source, :tag => s.version.to_s }
    s.source_files = 'BTDiscover/Classes/BTDiscover.h'
  end

  s.ios.deployment_target = '11.4'
  s.static_framework      = true
  s.pod_target_xcconfig   = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64', 'VALID_ARCHS' => 'arm64' }
  s.user_target_xcconfig  = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64', 'VALID_ARCHS' => 'arm64' }
  
  
  s.dependency 'ReactiveObjC'
  s.dependency 'pop'
  s.dependency 'YYText'
  s.dependency 'JXSegmentedView'

  s.dependency 'BTBaseKit'
  s.dependency 'BTNetwork'
  s.dependency 'BTLogger'
  s.dependency 'BTLocalization'
  s.dependency 'BTToast'
  s.dependency 'BTRouter'
  s.dependency 'BTGlobalConfig'

#  s.dependency 'BTAppLogService'
#  s.dependency 'BTUpLoadFileTool'

  s.dependency 'BTRTLAdapter'
  s.dependency 'BTMQTT'
  s.dependency 'BTRouter'
  s.dependency 'BTAssets'
  s.dependency 'BTUserInfo'
  s.dependency 'BTUserStateManager'
  s.dependency 'BTSystemSkin'
  s.dependency 'BTComponentsKit'
  s.dependency 'BTRtcEngine'
  
  
  s.prefix_header_contents = [
      '#import <Masonry/Masonry.h>',
      '#import <YYWebImage/YYWebImage.h>',
      '#import <SDWebImage/SDWebImage.h>',
      '#import <BTBaseKit/BTBaseKit.h>',
      '#import <BTLogger/BTLogger.h>',
      '#import <BTAssets/BTAssets.h>',
      '#import <BTLocalization/BTLocalization.h>',
      '#import <BTNetwork/BTNetwork.h>',
      '#import <BTToast/BTToast.h>',
      '#import <BTUserStateManager/BTUserStateManager.h>',
      '#import <BTRouter/BTRouter.h>',
      '#import <BTGlobalConfig/BTGlobalConfig.h>',
      '#import <ReactiveObjC/ReactiveObjC.h>',
      '#import <BTRTLAdapter/BTRTLAdapter.h>',
  ]
  
 s.subspec 'CoreFramework' do |ss|
    ss.vendored_frameworks = 'BTDiscover.framework'
    ss.resources           = 'BTDiscover.bundle'
  end

  # 以下为脚本依赖CoreFramework自动生成代码，勿动⚠️⚠️ 如CoreFramework有改动请删除。

 s.subspec 'MNL' do |ss|
    ss.vendored_frameworks = 'MNLDiscover.framework'
    ss.resources           = 'MNLDiscover.bundle'
  end


  s.subspec 'Core' do |ss|
    ss.source_files = 'BTDiscover/Classes/**/*.{h,m}'
    #ss.dependency 'BTDiscover/Resource'
  end
  
end
